var deleteDuplicates = function (head) {
  let dummyHead = new ListNode(0)
  let p = dummyHead
  p.next = head
  while (p.next) {
    let val = p.next.val
    if (p.next.next && p.next.next.val === val) {
      let next = p.next.next
      while (next && next.val === val) {
        next = next.next
      }
      p.next = next
    } else {
      p = p.next
    }
  }
  return dummyHead.next
}